home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / c / pro22 / cbgetrcu.c < prev    next >
Text File  |  1990-06-20  |  2KB  |  83 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbgetrcu.c    1.4 - 90/06/20" */
  5.  
  6. /* ansi headers */
  7. #include <errno.h>
  8.  
  9. /* library headers */
  10. #include <blkio.h>
  11. #include <lseq.h>
  12.  
  13. /* local headers */
  14. #include "cbase_.h"
  15.  
  16. /*man---------------------------------------------------------------------------
  17. NAME
  18.      cbgetrcur - get cbase record cursor
  19.  
  20. SYNOPSIS
  21.      #include <cbase.h>
  22.  
  23.      int cbgetrcur(cbp, cbrposp)
  24.      cbase_t *cbp;
  25.      cbrpos_t *cbrposp;
  26.  
  27. DESCRIPTION
  28.      The cbgetrcur function gets the position of the record cursor of
  29.      cbase cbp.  The cursor position is returned in the location
  30.      pointed to by cbrposp.
  31.  
  32.      cbgetrcur will fail if one or more of the following is true:
  33.  
  34.      [EINVAL]       cbp is not a valid cbase pointer.
  35.      [EINVAL]       cbrposp is the NULL pointer.
  36.      [CBELOCK]      cbp is not locked.
  37.      [CBENOPEN]     cbp is not open.
  38.  
  39. SEE ALSO
  40.      cbgetkcur, cbrcursor, cbsetrcur.
  41.  
  42. DIAGNOSTICS
  43.      Upon successful completion, a value of 0 is returned.  Otherwise,
  44.      a value of -1 is returned, and errno set to indicate the error.
  45.  
  46. ------------------------------------------------------------------------------*/
  47. int cbgetrcur(cbp, cbrposp)
  48. cbase_t *cbp;
  49. cbrpos_t *cbrposp;
  50. {
  51.     lspos_t lspos = NIL;
  52.  
  53.     /* validate arguments */
  54.     if (!cb_valid(cbp) || cbrposp == NULL) {
  55.         errno = EINVAL;
  56.         return -1;
  57.     }
  58.  
  59.     /* check if not open */
  60.     if (!(cbp->flags & CBOPEN)) {
  61.         errno = CBENOPEN;
  62.         return -1;
  63.     }
  64.  
  65.     /* check if not locked */
  66.     if (!(cbp->flags & CBLOCKS)) {
  67.         errno = CBELOCK;
  68.         return -1;
  69.     }
  70.  
  71.     /* get record cursor position */
  72.     if (lsgetcur(cbp->lsp, &lspos) == -1) {
  73.         CBEPRINT;
  74.         return -1;
  75.     }
  76.  
  77.     /* load return argument */
  78.     *cbrposp = lspos;
  79.  
  80.     errno = 0;
  81.     return 0;
  82. }
  83.